package com.zerosky.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.zerosky.crm.dao.RelationDAO;
import com.zerosky.crm.po.Relation;
import com.zerosky.crm.service.RelationService;

/**
 * Relation业务逻辑实现类
 * 
 * @author hugy;
 * @since 2017-06-09
 *
 */
@Service(value="relationService")
public class RelationServiceImpl implements RelationService {

	@Autowired
	private RelationDAO relationDAO; // Relation数据接口

	/**
	 * Relation列表
	 * 
	 * @author hugy;
	 * @since 2017-06-09
	 */
	@Transactional(propagation = Propagation.NOT_SUPPORTED) // 不开启事务
	public List<Relation> getRelationByRoleIdList(Integer RoleId) {
		return relationDAO.getRelationByRoleIdList(RoleId);
	}

	/**
	 * 新增信息
	 * 
	 * @author hugy;
	 * @since 2017-06-09
	 */
	@Transactional(propagation = Propagation.REQUIRED) // 创建一个事务，如果有则加入事务
	public void addRelation(List<Relation> list) throws Exception {
		relationDAO.addRelation(list);
	}

	/**
	 * 删除信息
	 * 
	 * @author hugy;
	 * @since 2017-06-09
	 */
	@Transactional(propagation = Propagation.REQUIRED) // 创建一个事务，如果有则加入事务
	public void deleteRelationById(Integer RoleId) throws Exception {
		relationDAO.deleteRelationById(RoleId);
	}

}
